
public class LLKMatrix {

	private int VSize = 0;
	private int HSize = 0;
	private int SeedCount = 0;
	private int matrix[][];
	
	public LLKMatrix(int h,int v, int s) {
		
		if((v*h)%2 ==0) {
			VSize = v;
			HSize = h;
			SeedCount = s;
			initMatrix(HSize,VSize);
		}
		
	}
	
	public void initMatrix(int hs,int vs) {
		//横向尺寸
		HSize = hs;
		//纵向尺寸
		VSize = vs;
		// 创建矩阵
		matrix = new int[HSize][VSize];
		int j = 0;
		int b = 0;
		for (int x = 0; x < HSize; x++) {
	      
			for(int y =0;y<VSize;y++) {
				j = 1-j;
				if(j==1) {
					b = ((x*HSize+y)/2) % SeedCount;
				}
				//按照单元格图片索引生成的有规律的矩阵
				matrix[x][y] =b;
			}
			
		}
		do {
			//随机变换矩阵
			shuffleMatirx();
			//如果不存在可连单元格,则重新变换
		}while(find() ==0);
		
		
		
	}
	
	
}
